uniform float mouseX;
uniform float mouseY;
uniform float lensRadius;
uniform float zoomLevel;
uniform sampler2D texture;
void main()
{
  vec4 c = texture2D( texture, gl_TexCoord[0].st );
  // Texture has pre-multiplied alpha - the color does not.
  vec4 color;
  color.rgb = gl_Color.rgb;
  color.a = gl_Color.a;
  
  //float lensRadius = 0.14;//now its uniform variable
  //if we need the mouse to be in the center of the lens,
  //change the following lines - now we make the lens to be left/up 
  //from the position of the mouse pointer
  float mouseXNew = mouseX - lensRadius;//mouseX
  float mouseYNew = mouseY + lensRadius;//mouseY
  if(mouseXNew < 0.0) mouseXNew = 0.0;
  if(mouseYNew >1.0) mouseYNew = 1.0;
  
  vec2 planeCoords = vec2(gl_TexCoord[0].st);
  float rSquared = (planeCoords.x - mouseXNew)*(planeCoords.x - mouseXNew) + 
  		(planeCoords.y - mouseYNew)*(planeCoords.y - mouseYNew);
  float r = sqrt(rSquared);
  float k = 0.0;
  	
  if(rSquared < pow(lensRadius, 2.0)-0.0005)
  {
	color.a = 0.0;
	vec3 ve = vec3(0.0,0.0,0.0);
    color.rgb = ve;
    gl_FragColor= c* color;
  }
  else if(rSquared < pow(lensRadius, 2.0))//make the edge of the lens visible
  {
	gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
  }
  else
  {
  	gl_FragColor = c * color;
  }
}


